/*
 * MoveType.java
 * 
 * Created on May 30, 2007, 7:35:23 AM
 * 
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
import java.util.StringTokenizer;

/**
 *
 * @author tim
 */
public class MoveType 
{
     public static void convert(String line, int lineNumber, Assembled assembled)
     {
	StringTokenizer tokenizer = new StringTokenizer(line, " ,");
	int[] build = new int[4];
	build[0] = 5;
	build[1] = table(tokenizer.nextToken());
	build[2] = Memory.memory(tokenizer.nextToken());
	build[3] = lineNumber;
	
	if(build[1] == -1)
	{
	     assembled.addError("Unrecognized move type " + line + " at line number " + lineNumber);
	}
	
	assembled.addLine(build);
     }
     public static int table(String command)
     {
	  if(command.equals("mfhi"))
	       return 0;
	  else if(command.equals("mflo") || command.equals("mflow"))
	       return 1;
	  else
	       return -1;
     }
}
